<?php
/**
 * @copyright meila.com
 * @author wangtao5@
 * @name 发布接口
 * @param
 *         $nick = 作用
 *
 *
 */
include('../../__global.php');
include(SERVER_ROOT_PATH.'/include/config/dataRule/ml_datarule_album.php');
class aj_albumreply extends ml_controller
{
    //执行默认检查的参数集合
    protected  $_param_check = array(
            'albumfeed_rid' => array('type'=>ML_DATATYPE_ALNUM, 'is_must'=>true, 'len_limit'=>array('eq'=>ML_RID_LEN)),
    );
    //错误描述
    protected  $_error_msg = array(
            'albumfeed_rid' => 'albumfeed_rid',
    );
    private $_uid;
    private $_page;
    
    /**
     * 初始化参数
     */
    function initParam()
    {
        //必选项
        $this->_option['albumfeed_rid'] = Tool_input::input('albumfeed_rid', 'G', '');
        
        $this->_page = (int)Tool_input::input('page', 'G', 1);
        $this->_page = $this->_page<1 ? 1 : $this->_page;
        
        $this->_uid = $this->__visitor['uid'];
    }
    
    /**
     * @develop_template
     * 检查参数合法性
     */
    function checkParam()
    {
        $this->check_option();
    }
    
    /**
     * @develop_template
     * 核心业务逻辑
     */
    function main(){
        $data = $this->get_list();
        if(!$data)
            $this->api_output(ML_RCODE_HACK);
        $this->api_output(ML_RCODE_SUCC,$data);
    }
    
    function get_list(){
        $start = ($this->_page-1)*ML_ALBUM_ALBUMREPLY_PAGE;
        $oRdsCount = new ml_model_rdsCount();
        $count = $oRdsCount->getAlbumreplyCnt($this->_option['albumfeed_rid']);
        $count = (int)$count;
        if($count>0 && $start<$count){
            $oAlbumreply = new ml_model_album_dbAlbumreply();
            $rs = $oAlbumreply->get_list_by_albumfeed_rid($this->_option['albumfeed_rid'],$start,ML_ALBUM_ALBUMREPLY_PAGE);
            if(!$rs)
                return false;
            $list = $oAlbumreply->get_data();
            $bizAlbumreply = new ml_biz_feed_albumreply();
            $option['uid'] = $this->_uid;
            $option['data'] = $list;
            if($this->_page == 1){
                $option['is_hide'] = true;
            }
            $bizAlbumreply->initParam($option);
            $data = $bizAlbumreply->create_html();
            $list = $data;
        }else{
            $list = array();
        }
        return array('data'=>$list,'count'=>$count);
    }

}

new aj_albumreply();
